package com.gz.springcloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.util.concurrent.TimeUnit;

//注入RestTemplate bean对象
@Configuration
public class CustomizationBean {

    @Bean
    //添加@LoadBalanced 给RestTemplate赋予负载均衡的能力
    //默认是使用轮询算法
    @LoadBalanced
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }
}
